   var editor;
	KindEditor.ready(function(K) {
		editor = K.create('textarea[name="Description"]', {
			allowFileManager : true
		});
	});
	$(document).ready(function(){
	  $("#addPicturesBtn").bind('click',function(){
		   $('#uploadPicModal').modal('show')				  
		});
	  $("#uploadBtn").bind('click',function(){
	  	   //$('#prodForm').submit();
	  	   //$('#prodForm').validation()
	  	   return true ;
	   });
	  $('#upfrm').bind('load',function(event){
		   var upfrmDoc = document.getElementById("upfrm").contentDocument||window.frames["upfrm"].document ;
		   data = $(upfrmDoc).find("pre").html()

		   if(!data){
			   return;
		   }   
		   var urlJson = jQuery.parseJSON(data);
		   $("#uploadPicModal div.alert").removeClass("hide");
		   if(urlJson.Result){
		   		$("#uploadPicModal div.alert").removeClass("alert-error").addClass("alert-success");
		   		//$("#uploadPicModal div.alert").removeClass("alert-error");
		   		//$("#uploadPicModal div.alert").addClass("alert-success");		   				   
		   		$("#uploadPicModal div.alert>strong").text("OK, ");
		   		$("#uploadPicModal div.alert").children("span").text(urlJson.Msg);
		   		$("#picUrl").val(urlJson.Url);
		   		$("#selImg"+ urlJson.Seq).attr("src",urlJson.Url)
		   }else
		   {
		   		$("#uploadPicModal div.alert").removeClass("alert-success");
		   		$("#uploadPicModal div.alert").addClass("alert-error");		   
		   		$("#uploadPicModal div.alert").children("strong").text("Warning, ");
		   		$("#uploadPicModal div.alert").children("span").text(urlJson.Msg);
		   		$("#picUrl").val("");
		   }
		   alert(data);		   
		   return true ;
	  });	
      $("#pics_list span.removeImage>img").each(function(){
      	  $(this).bind('click',function(){
      	  	   $.ajax({
				  url: "/adm/prod/delPic",
				  cache: false,
				  success: function(html){
				     $("#results").append(html);
				  }
				});
      	  });
      });
	});